package com.zego.wawaji.third.zego.im.callback;

import com.zego.wawaji.base.observer.MsgMgr;
import com.zego.wawaji.third.zego.im.listener.ZegoListener;
import com.zego.zegoliveroom.callback.IZegoRoomCallback;
import com.zego.zegoliveroom.entity.ZegoStreamInfo;

/**
 * 直播房间回调
 */
public class ZegoRoomCallback implements IZegoRoomCallback {
    private ZegoListener mListener;

    public ZegoRoomCallback(ZegoListener listener) {
        this.mListener = listener;
    }

    /**
     * 因为登陆抢占原因等被挤出房间
     */
    @Override
    public void onKickOut(int reason, String roomId) {
    }

    /**
     * 与 server 断开
     */
    @Override
    public void onDisconnect(int errorCode, String roomId) {
    }

    /**
     * 中断后重连
     */
    @Override
    public void onReconnect(int errorCode, String roomId) {
    }

    /**
     * 临时中断
     */
    @Override
    public void onTempBroken(int errorCode, String roomId) {
    }

    /**
     * 房间流列表更新
     */
    @Override
    public void onStreamUpdated(int type, ZegoStreamInfo[] streamList, String roomId) {
    }

    /**
     * 更新流的额外信息
     */
    @Override
    public void onStreamExtraInfoUpdated(ZegoStreamInfo[] streamList, String roomId) {
    }

    /**
     * 只接收当前房间，当前主播发来的消息
     */
    @Override
    public void onRecvCustomCommand(final String fromUserId, final String fromUserName, final String content, final String roomId) {
        MsgMgr.getInstance().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (mListener != null)
                    mListener.onRecvCustomCommand(fromUserId, fromUserName, content, roomId);
            }
        });
    }
}
